ifndef TOOLSET
USAGE:
    @echo 'USAGE: gmake -f <makefile> TOOLSET=<toolset>'
    @echo '   <toolset> from one of the following:'
    @echo '      qhdl    - Modeltech, Mentor Graphics'
    @echo '      vcom    - ModelSim, Modeltech'
    @echo '      synopsys - scs/vcs,       Synopsys'
    @echo '      cadence - ncvlog/ncvhdl,       Cadence'
endif

ifeq (${TOOLSET}, qhdl)
  COMPILER = qvhcom ${DEBUG} ${LIBS} -93 -source $<
  VCOMPILER = qvlcom ${DEBUG} ${LIBS} -93 -source $<
  ELABORATE =
  DEBUG =
  LIBS =  -work ${LIB_OBJ}
#  SDF = -sdfmax /tb/dut=clk_gate_flat/fbound_flat.sdf
  SDF =
  VLIB = gatelib_v
  SIM = qhsim -L ${VLIB} ${SDF}  -lib ${LIBNAME} ${TBNAME} -c -do "run ${SIMTIME};quit" > ${LIBNAME}/sim.log
  SIMI = qhsim -L ${VLIB} ${SDF}  -lib ${LIBNAME} ${TBNAME}
  MKLIB = qhlib ${LIB_OBJ}
  MKWORK = 
endif

ifeq (${TOOLSET}, vcom)
  COMPILER = vcom ${DEBUG} ${LIBS} -93 -source $<
  VCOMPILER = vcom ${DEBUG} ${LIBS} -93 -source $<
  ELABORATE =
  DEBUG =
  LIBS =  -work ${LIB_OBJ}
#  SDF = -sdfmax /tb/dut=clk_gate_flat/fbound_flat.sdf
  SDF =
  VLIB = gatelib_v
  SIM = qhsim -L ${VLIB} ${SDF}  -lib ${LIBNAME} ${TBNAME} -c -do "run ${SIMTIME};quit" > ${LIBNAME}/sim.log
  SIMI = vsim -L ${VLIB} ${SDF}  -lib ${LIBNAME} ${TBNAME}
  MKLIB = vlib ${LIB_OBJ}
  MKWORK = 
endif


ifeq (${TOOLSET}, synopsys)
  COMPILER = vhdlan ${DEBUG} ${LIBS} $<
  VCOMPILER = vlogan ${DEBUG} ${LIBS} $<
  ELABORATE = scs ${LIBNAME}.${TBNAME} -mhdl ${EDEBUG} -exe ./${LIBNAME}/scsim
  DEBUG = 
#  EDEBUG = -time ps -verilogcomp "+cli -I"
  EDEBUG = -time ps -time_res ps -verilogcomp "+cli -I"
  SIM = run_scsim.pl ${LIBNAME}/scsim ${SIMTIME} ${LIBNAME}/sim.log
  LIBS = -work ${LIBNAME}
  MKLIB = mkdir ${LIB_OBJ} 
  MKWORK = mkdir  ../obj/${TOOLSET}/work
endif

ifeq (${TOOLSET}, cadence)
  COMPILER = ncvhdl -V93 ${DEBUG} -Work ${LIBNAME}  $<
  VCOMPILER = ncvlog -nocopyright -work ${LIBNAME} $<
  ELABORATE = ncelab ${EDEBUG}  ${LIBNAME}.${TBNAME}:A -snapshot  ${TBNAME}
  DEBUG = 
#  EDEBUG = -time ps -verilogcomp "+cli -I"
  EDEBUG = -timescale '1 ns / 1 ps' -Work ${LIBNAME} -V93
  SIM = run_ncsim.pl ${LIBNAME}.${TBNAME} ${SIMTIME} ${LIBNAME}/sim.log
  LIBS = 
  MKLIB = mkdir ${LIB_OBJ} 
  MKWORK = mkdir  ../obj/${TOOLSET}/work
endif

all: do_all

clean:
    rm -rf ${LIBNAME}/scsim ${LIBNAME}/scsim.db.dir *.log csrc
    rm -rf simv.daidir sim_common *.wlf

